﻿#ifndef TCPFILEGET_H
#define TCPFILEGET_H

#include <QObject>
#include <QAbstractSocket>
#include <QTcpServer>
#include <QTcpSocket>
#include <QFile>

class tcpFileGet: public QObject
{
    Q_OBJECT
public:
    tcpFileGet();

    QString m_listenPort;

    void openlisten();
    void closelisten();

signals:
    void sig_GetProgress(int);
    void sig_GetError(QString);

private:
    QTcpServer m_tcpServer;
    QTcpSocket *m_tcpServerConnection;
    qint64 m_totalBytes;
    qint64 m_bytesReceived;
    qint64 m_fileNameSize;
    QString m_fileName;
    QFile *m_localFile;
    QByteArray m_inBlock;

private slots:
    void acceptConnection();
    void updateServerProgress();
    void displayError(QAbstractSocket::SocketError socketError);


};

#endif // TCPFILEGET_H
